package com.amado.course45mysql02.service.impl;

import java.util.List;

import com.amado.course45mysql02.dao.EmployeePageDao;
import com.amado.course45mysql02.domain.Page;
import com.amado.course45mysql02.domain.Student;
import com.amado.course45mysql02.service.StudentService;

public class StudentServiceImpl implements StudentService {
	private EmployeePageDao employeePageDao = new EmployeePageDao();
	@Override
	public Page<Student> page(int pageNumber, int pageSize) {
		//查询总共有多少条数据
		int count = employeePageDao.count();
		Page<Student> page = new Page();
		//set条数
		page.setCount(count);
		//计算有多少页
		int totalPage = count/pageSize;
		//计算有多少页
		totalPage =totalPage+ (count%pageSize==0?0:1);
		//设置一个有多少页
		page.setTotalPage(totalPage);
		//设置分页查询数据
		List<Student> data = employeePageDao.limit(pageNumber, pageSize);
		page.setData(data);
		return page;
	}	

}
